<!DOCTYPE html>
<html lang="en">
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>订单详情_{$webname}</title>
<!--公共样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/css/reset.css">
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/css/common.css">
<!--公共样式结束-->
<!--私有样式开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/css/page_order.css">
<!--私有样式结束-->
<!--FontAwesome开始-->
<link rel="stylesheet" type="text/css" href="{$NOW_THEME_URL}/Assets/plugins/FontAwesome/css/font-awesome.min.css">
<!--FontAwesome结束-->
<!--核心JS开始-->
<script src="{$NOW_THEME_URL}/Assets/js/jquery.min.js"></script>
<script src="__PUBLIC__/Js/jquery-migrate-1.2.1.min.js"></script> 
<script type="text/javascript" src="__PUBLIC__/Plugins/artDialog/jquery.artdialog.js?skin=bootstrap"></script>
<script type="text/javascript" src="__PUBLIC__/Plugins/artDialog/plugins/iframeTools.js"></script>
<!--核心JS结束-->
<script type="text/javascript">
	$(function(){
		$('#goBack').on('click',function(){
			window.history.back();
		});
		
		/*右侧导航点击事件*/
		$('.hb_right').click(function(){
			$(".wrapper").toggleClass("a");
			$(".nav_box").toggleClass("b");
		});
		
		/*右侧导航二级*/
		$('.erji').click(function(){
			$(this).find("ul").toggleClass("c");
		});
	});
</script>

<style type="text/css">
#opreate_status {
	line-height:100%;
	border-bottom:#CCC 1px solid;
	padding-bottom:5px;
}
#opreate_status a{
	display:inline-block;
	margin:5px;
	padding:8px;
	color:#FFF;
	background-color:#090;
}
#opreate_status .nextone {
	background-color:#FC0;
}
#opreate_status .preone {
	background-color:#FC0;
}
.editAttr{
	background-color:green;
	float:right;
	padding: 2px 4px;
	color:#FFFFFF;
	cursor:pointer;
}
.entitle{
	font-size:16px;
	font-weight:bold;
}
</style>
</head>
<body>
<!-- 头部开始-->
<include file="Public:header"/>
<!-- 头部结束-->
<!--主体开始-->
<div id="pageHome">
	<!--主体盒子开始-->
    <div id="wrapper" class="wrapper radius_5 bg_white">
    	<!--面包屑导航开始-->
        <ul class="pagePosition clearfix">
        	<li><a href="{:U('Index/index')}"><i class="icon-home"></i> 首页</a></li>
            <li><i class="icon-angle-right"></i></li>
            <li> <a href="{:U('Order/order_index')}">订单管理</a></li>
			<li><i class="icon-chevron-right"></i></li>
            <li><a href="#">订单详情</a></li>
        </ul>
        <!--面包屑导航结束-->
        <div class="space_hx">&nbsp;</div>
        <!--订单详情开始-->
        <div class="box_order_detail">
        	<div id="opreate_status" class="clearfix">
				{$detail.status|getOrderDeal=###,$detail['id']}
				<a data-id="{$detail.id}" class="orderbak">添加备注</a>
				<notempty name="data.pre">
					<a href="{$data.pre}" class="preone">上一条</a>
				<else />
					<a href="javascript:void(0)">无上一条</a>&nbsp;
				</notempty>
				<notempty name="data.next">
					<a href="{$data.next}" class="nextone">下一条</a>&nbsp;
				<else />
					<a href="javascript:void(0)">无下一条</a>&nbsp;
				</notempty>
			</div>
        	<ul>
        		<li>订单号：{$detail.orderno}</li>
        		<li>所属餐厅：{$detail.outletname}</li>
                <li>菜品金额：￥{$detail.dishesfee}</li>
                <li>酒水金额：￥{$detail.drinkfee}</li>
                <li>服务金额：￥{$detail.shipfee}</li>
                <li>优惠金额：￥{$detail.cardfee}</li>
                <li>调整金额：￥{$detail.b_price}</li>
                <li>实付金额：￥{$detail['orderfee']+$detail['b_price']}</li>
                <li>结算金额：￥{$detail.settlefee|round=###}</li>
            	<li>订单状态：{$detail.status|get_array_key='ORDER_STATUS',###}</li>
            	<li>下单时间：{$detail.addtime|date='m-d H:i',###}</li>
            	<eq name='detail.isyuding' value='1'>
            		<li>配送时间：{$detail.sdltime|date="m-d H:i",###} ~ {$detail.edltime|date="m-d H:i",###}(预订单)</li>
            	</eq>
            </ul>
            
            <volist name="list" id="v">
	            <dl class="clearfix">
	                <!-- <dt><img src="" width="100" height="100"/></dt> -->
	                <dd class="box_sc_dl_middle">
	                    <strong>{$v.title}</strong>
	                    <span>单价：{$v.price}</span>
	                    <span>数量：{$v.amount}
	                    	<notempty name="v.attr">
	                    		<p class="editAttr" css="isshow" id="{$v.id}">显示属性</p>
	                    	</notempty>
	                    </span>
	                </dd>
	                <dd id="tr_{$v.id}" style="display:none">
	                	<volist name="v.attr" id="vo">
	                		<div><p class="entitle">{$vo.title}：</p>
	                			<volist name="vo.config" id="k">
	                				<p>{$k.title} <notempty name="k.mprice">(￥{$k.mprice})</notempty></p>
	                			</volist>
	                		</div>
	                	</volist>
	                </dd>
	            </dl>
			</volist>
            
            <div class="space_hx">&nbsp;</div>
            
            <notempty name="orderbak">
	            <ul>
	            	<volist name="orderbak" id="v">
	            		<li>{$key+1}、{$v.remark}</li>
	            	</volist>
	            </ul>
            </notempty>
            
            <ul>
            	<li>收 货 人：  {$detail.username}</li>
            	<notempty name='detail.cnaddress'>
            		<li>收货地址：{$detail.cnaddress}</li>
				<else />
					<li>收货地址：{$detail.address}</li>
				</notempty>
            	<li>联系电话：{$detail.mobile}</li>
            	<li>备　　注：{$detail.content}</li>
            	<li>发　　票：<eq name='detail.isinvoice' value='1'>抬头（{$detail.invoice_title}）<else />不需要</eq></li>
            	<notempty name='detail.isdrink'><li>免费饮品：{$drink[$detail['isdrink']]['zh-cn']}</li></notempty>
            </ul>
          	<!--   订单操作记录
          	<volist name="opreate" id="v">  
            <ul>
            	<li><empty name="v.username">
					客户自己
					<else />
					{$v.username}({$v.rname})
					</empty>
				</li>
            	<li>操作说明：{$v.ctitle}</li>
            	<li>操作时间：{$v.addtime|date='Y-m-d H:i:s',###}</li>
            </ul>
            </volist>--> 
        </div>
        <!--订单详情结束-->
    </div>
    <!--主体盒子结束 -->
    <!--导航盒子开始-->
    <include file="Public:menu" />
    <!--导航盒子结束-->
</div>
<script type="text/javascript">
var url = "{:U('Order/order_index')}";
function reloadOrder(){
	window.location.reload();
}

jQuery(document).ready(function() {
	
	$('#status').on("change",function(){
		var url = "{:U('Order/order_index')}";
		url+="&status="+$(this).val();
		ajaxOrder(url);
	});
	
	//分配订单到门店配送员'
	$('.order_delivery').live("click",function(){
		var id = $(this).attr("data-id");
		var url = '{:U("Order/order_delivery")}'+'&id='+id;
		window.location.href=url;
		/*art.dialog.open('{:U("Order/order_delivery")}'+'&id='+id,{
			title:'分配订单到门店配送员', width:500,height:200,fixed:true,top:60
		});*/
	});
	
	//配送员到达餐厅
	$('.order_daoda').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_daoda')}";
		dealOrder(durl,id);
	});
	
	//退回订单
	$('.order_revert').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_revert')}";
		dealOrder(durl,id);
	});
	
	//配货完成
	$('.order_hasget').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_hasget')}";
		dealOrder(durl,id);
	});
	
	//配货完成
	$('.order_delivery').live("click",function(){
		var id   = $(this).attr("data-id");
		var durl = "{:U('Order/order_delivery')}";
		dealOrder(durl,id);
	});
	
	//确认收货
	$('.order_send').live("click",function(){
		var id   = $(this).attr("data-id");
		//var durl = "{:U('Order/order_confirm')}";
		//dealOrder(durl,id);
		var url = '{:U("Order/order_send")}'+'&id='+id;
		window.location.href=url;
		/* art.dialog.open('{:U("Order/order_confirm")}'+'&id='+id,{
			title:'确认收货', width:500,height:200,fixed:true,top:60
		}); */
		
	});
	
	//显示隐藏属性
	$(".editAttr").click(function(){
		var id  = $(this).attr("id");
		var css = $(this).attr("css");
		
		if(css=="isshow"){
			$("#tr_"+id).show();
			$(this).attr("css","ishide");
			$(this).text("隐藏属性");
		}else{
			$("#tr_"+id).hide();
			$(this).attr("css","isshow");
			$(this).text("显示属性");
		}
	});
	
	//客户拒签
	$('.order_refused').live("click",function(){
		var id  = $(this).attr("data-id");
		var url = '{:U("Order/order_refused")}'+'&id='+id;
		window.location.href=url;
	});
	
	//订单备注
	$('.orderbak').on('click',function(){
		var id  = $(this).attr("data-id");
		var url = '{:U("Order/order_bak")}'+'&id='+id;
		window.location.href=url;
	});
	
	//打印订单
	$('.order_print').live("click",function(){
		var id   = $(this).attr("data-id");
		art.dialog.open('{:U("Order/order_print")}'+'&id='+id,{
			title:'打印订单', width:320,height:400,fixed:true,top:60
		});
	});
});

function dealOrder(url,id){
	$.post(url,{'id':id},function(data){
		if(data.status == 1){
			reloadOrder();
		}
		art.dialog.alert(data.info);
	});
}

function ajaxOrder(url){
	$.ajax({
		url: url,
		dataType: "html",
		type: "get",
		cache: false,
		async:false,
		success: function(html){
			$("#detail_order").html(html);
			return false;
		}
	});
}
$(document).keydown(function(event){
	
	if(event.keyCode == 37){
		var url = $('.preone').attr("href");
		if(url){
			window.location.href = url ;
		}else{
			art.dialog.alert("没有上一条");
		}
		
	}else if (event.keyCode == 39){
		var url = $('.nextone').attr("href");
		if(url){
			window.location.href = url ;
		}else{
			art.dialog.alert("没有下一条");
		}
	}
	
});
</script>
<!--主体结束-->
</body>
</html>